package com.health.db.dao.sm.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.health.db.dao.ServiceInterface;
import com.health.db.dao.sm.IGoodsGiftListDao;
import com.health.db.mapper.GoodsGiftListMapper;
import com.health.db.model.GoodsGiftList;
import com.health.db.model.GoodsGiftListExample;
import com.health.redis.RedisConstants;

@Component("goodsGiftListDao")
public class GoodsGiftListDaoImpl extends ServiceInterface implements
	IGoodsGiftListDao {

	@Autowired
	GoodsGiftListMapper goodsGiftListMapper;
	
	
	String channel = ":1:";
	String gooddsId=":2:";
	
	@Override
	public GoodsGiftList selectByChannel(GoodsGiftListExample example) {
		// TODO Auto-generated method stub
		getRedisOperatiorLogic();
		String key=RedisConstants.GoodsListMapper+channel+example.getChannel()+gooddsId+example.getGoodsId();
		Object object=null;
		GoodsGiftList  list=null;
		if(redisOperatiorLogic.isJedisIsConnected())
		{
			object = redisOperatiorLogic.readObject(key, getOrderRedisGroupNo("1"));
		}
		if(null!=object){
			
			if (!object.equals("")) {
				list =  (GoodsGiftList) object;
			}
		}
		else
		{
			list=goodsGiftListMapper.selectByChannel(example);
			if(redisOperatiorLogic.isJedisIsConnected())
			{
			redisOperatiorLogic.setEx(key, list, getOrderRedisGroupNo("1"));
			}
		}
		return list;
		
	}


	public GoodsGiftListMapper getGoodsGiftListMapper() {
		return goodsGiftListMapper;
	}


	public void setGoodsGiftListMapper(GoodsGiftListMapper goodsGiftListMapper) {
		this.goodsGiftListMapper = goodsGiftListMapper;
	}

}
